﻿using System.Collections.Generic;
using System.IO;
using Coder.Object2Report;
using Coder.Object2Report.Renders.NPOI;

namespace Fee.IO.Exporters
{
    public abstract class BaseExportor<T> : IExportor<T>
    {
        protected abstract string SheetName { get; }

        public void ToExcel(Stream stream, IEnumerable<T> projects, string templateFileName = null)
        {
            var render = new XssfExcelReader(stream, SheetName, templateFileName);
            var report = CreateReportStructure(render);

            report.Write(projects);
        }

        protected abstract Report<T> CreateReportStructure(RenderBase render);
    }
}